<!DOCTYPE html>
<html>
    <head>
        <!-- 页面meta -->
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>畅购</title>
        <meta name="description" content="畅购">
        <meta name="keywords" content="畅购">
        <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
        <!-- 引入样式 -->
        <link rel="stylesheet" href="/plugins/font-awesome/css/font-awesome.min.css">
        <link rel="stylesheet" href="/css/style.css">
        <link rel="stylesheet" href="/plugins/elementui/index.css">
        <style>
            .el-dropdown-link {
                cursor: pointer;
                color: #409EFF;
            }
            .el-icon-arrow-down {
                font-size: 12px;
            }
        </style>
        <script src="/js/moment.min.js"></script>
    </head>
    <body class="hold-transition">
        <div id="app">
            <div class="content-header">
                <h4>商品评价</h4>
                <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
                    <el-button><a href="javascript:void(0)" οnclick="location.reload()">刷新</a></el-button>
                    <!--<el-breadcrumb-item>预约管理</el-breadcrumb-item>-->
                </el-breadcrumb>
            </div>
            <div class="app-container">
                <div class="box">
                    <div class="filter-container">
                        <table>
                            <tr>
                                <td>筛选查询</td>
                                <td></td>
                                <td></td>
                                <td><button @click="findPage1()" class="dalfBut">查询结果</button></td>
                            </tr>
                            <tr>
                                <td>输入搜索：<el-input placeholder="评价关键词/商品名称" v-model="pagination.queryString" style="width: 200px;" class="filter-item" ></el-input></td>
                                <td>商品分类：<el-input placeholder="请选择商品分类" v-model="pagination.querysort" style="width: 200px;" class="filter-item">查询</el-input></td>
                                <td>
                                    用户昵称：<el-input placeholder="输入用户昵称" v-model="pagination.queryname" style="width: 200px;" class="filter-item" ></el-input>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div>
                        <table>
                        <td  width="60%"><template><i class="el-icon-s-operation"></i></template>数据列表</td>
                            <td><el-dropdown @click="changePage()">
                                  <span class="el-dropdown-link">
                                    显示条数<i class="el-icon-arrow-down el-icon--right"></i>
                                  </span>
                                <el-dropdown-menu slot="dropdown">
                                    <el-dropdown-item  command="5">5</el-dropdown-item>
                                    <el-dropdown-item  command="10">10</el-dropdown-item>
                                    <el-dropdown-item  command="25">25</el-dropdown-item>
                                    <el-dropdown-item  command="50">50</el-dropdown-item>
                                </el-dropdown-menu>
                            </el-dropdown>
                            </td>
                            <td ><el-dropdown>
                                  <span class="el-dropdown-link">
                                    排序方式<i class="el-icon-arrow-down el-icon--right"></i>
                                  </span>
                                <el-dropdown-menu slot="dropdown">
                                    <el-dropdown-item>时间升序</el-dropdown-item>
                                    <el-dropdown-item>时间降序</el-dropdown-item>
                                </el-dropdown-menu>
                            </el-dropdown></td>

                        </table>
                    <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                        <el-table-column type="selection" value="id" width="55"></el-table-column>
                        <el-table-column prop="id" label="编号" align="center"></el-table-column>
                        <el-table-column prop="username" label="用户昵称" align="center"></el-table-column>
                        <el-table-column prop="name" label="商品名称" align="center"></el-table-column>
                        <el-table-column prop="evaluate" label="评价" align="center">
                            <template slot-scope="scope">
                                <i></i>
                                <i v-if="scope.row.evaluate===1" class="el-icon-close"><image width="30px" height="9px" src="/img/1star.png"></image></i>
                                <i v-else-if="scope.row.evaluate===3" class="el-icon-close"><image width="30px" height="9px"  src="/img/3star.png"></image></i>
                                <i v-else class="el-icon-check"><image width="80px" height="20px"  src="/img/5star.png"></image></i>
                            </template>
                        </el-table-column>
                        <el-table-column prop="ip" label="ip地址" align="center"></el-table-column>
                        <el-table-column prop="createTime" label="评价时间" align="center">
                            <template slot-scope="scope">{{scope.row.createTime| dateFilter}}</template>
                        </el-table-column>
                        <el-table-column prop="isReturn" label="是否显示" align="center">
                            <template slot-scope="scope">
                                <el-switch
                                        v-model="scope.row.isReturn"
                                        active-color="#13ce66"
                                        inactive-color="#ff4949"
                                        active-value="1"
                                        inactive-value="0"
                                        @change="changeSwitch(scope.row)"
                                />
                            </template>
                        </el-table-column>
                        <el-table-column label="操作" in-width="20%" align="center">
                            <template slot-scope="scope">
                                <el-button type="primary" size="mini" @click="checkEvaluate(scope.row.id)">查看</el-button>
                                <el-button type="primary" size="mini" @click="deleteEvaluate(scope.row.id)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    </div>
                    <div>
                    <div style="float: left">
                    <el-column type="selection" value="id" width="55">全选</el-column>&nbsp;&nbsp;&nbsp;
                    <el-button>关闭订单</el-button>
                    <el-button>确定</el-button>
                    </div>
                    <div class="pagination-container">
                        <el-pagination
                            class="pagiantion"
                            @current-change="handleCurrentChange"
                            :current-page="pagination.currentPage"
                            :page-size="pagination.pageSize"
                            layout="total, prev, pager, next, jumper"
                            :total="pagination.total">
                        </el-pagination>
                    </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
    <!-- 引入组件库 -->
    <script src="/js/vue.js"></script>
    <script src="/plugins/elementui/index.js"></script>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script src="/js/axios-0.18.0.js"></script>

    <script>
        //过滤器
        Vue.filter("dateFilter",function (date,format) {
            return moment(date).format(format || "YYYY-MM-DD HH:mm:ss");
        });

        var vue = new Vue({
            el: '#app',
            data:{
                value:10,//选择分页数据
                pagination: {//分页相关模型数据
					  currentPage: 1,//当前页码
					  pageSize:10,//每页显示的记录数
					  total:0,//总记录数
                      queryString:null,//查询条件
                      querysort:null,//查询条件
                      queryname:null//时间
				},
				dataList: [],//当前页要展示的分页列表数据
                formData: {},//表单数据
                dialogFormVisible: false,//增加表单是否可见
                dialogFormVisible4Edit:false,//编辑表单是否可见

            },
            //钩子函数，VUE对象初始化完成后自动执行
            created() {
                this.findPage();
            },
            methods: {
                changeSwitch(row){
                    var falg = row.status === '1' ? 1 : 0
                    axios.get('/findGoods/evaluChangeReturn/' + falg,param
                    ).then((res) => {
                        if (res.data.flag) {
                            this.$message.success(res.data.message)
                        }else {
                            this.$message.error(res.data.message)
                        }


                    });
                },
                //翻页
                handleCurrentChange(){
                    this.findPage();
                },
                //模糊查询
                findPage1(){
                    this.pagination.currentPage=1;
                    this.findPage();
                },
                //分页查询
                findPage() {
                    //发送ajax请求，提交参数（页码，每页显示记录数，查询条件）
                    var param={
                        page:this.pagination.currentPage,
                        size:this.pagination.pageSize,
                        name: this.pagination.queryString,
                        sort: this.pagination.querysort,
                        username:this.pagination.queryname
                    }
                    axios.post("/worder/evaluatelist/"+this.pagination.currentPage+"/"+this.pagination.pageSize,param).then((res)=>{
                        if (res.data.flag) {
                            console.log(this.pagination.currentPage)
                            this.dataList = res.data.data.rows;
                            this.pagination.total = res.data.data.total;
                        }
                    });
                },
            },
            created:function () {
                this.findPage();
            }
        })
    </script>
</html>